import axios from '@/api/fetch';
import SERVER from '@/api/server';

// 获取配件信息
export const getpartinfo = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo`, { params });
// 获取配件信息(根据分类)
export const getSortList = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo/getSortList`, { params });
// 查询开票信息（分页）
export const selectKP = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo/selectKP`, { params });
//查询配件类别
export const selectCategories = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo/selectCategories`,  {params} );
// 获取配件供应商信息
export const getPartSupplier = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo/getPartSupplier`,  {params} );
// 修改
export const updatePartPrice = params => axios.put(`${SERVER.CMSCLOUD_WMS}/part/partinfo/updatePartPrice`,  params );
// 批量导入
export const importPartPrice = params => axios.put(`${SERVER.CMSCLOUD_WMS}/part/partinfo/importPartPrice`,  params );
// 修改+新增（分类页面）
export const updateById = params => axios.put(`${SERVER.CMSCLOUD_WMS}/part/partinfo/updateById`,  params );
// 查询备件价格信息
export const getPartPrice = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo/getPartPrice`, {params});
// 查询备件替换件信息
export const getSubPartList = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo/getSubPartList`, {params});
// 新增备件替换件关系
export const addPartRelation = params => axios.post(`${SERVER.CMSCLOUD_WMS}/part/partinfo/addPartRelation`,  params);
// 删除备件替换件关系
export const deletePartRelation = params => axios.post(`${SERVER.CMSCLOUD_WMS}/part/partinfo/deletePartRelation`,  params);
// 修改备件信息
export const updatePartInfo = params => axios.post(`${SERVER.CMSCLOUD_WMS}/part/partinfo/updatePartInfo`,  params);
// 批量导入
export const importPartList = params => axios.put(`${SERVER.CMSCLOUD_WMS}/part/partinfo/importPartList`,  params);
// 删除上传图片
export const deletePartPicFile = params => axios.post(`${SERVER.CMSCLOUD_WMS}/part/partinfo/deletePartPicFile`,  params);
// 获取物料组
export const getMaterialList = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/material`,  params);
// 获取车型
export const getCarModelList = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/carModel`,  params);
// 备件主信息导出
export const exportExcel = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo/export`,  {params} );
// 适用车型下拉框
export const findModelList = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo/findModelList`,  {params} );
// 适用车型下拉框
export const findPartTypeList = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo/findPartTypeList`,  {params} );

// // 店端库存查询
// export const stockQuery = params => axios.get(`${SERVER.CMSCLOUD_WMS}/part/partinfo/stockQuery`,  {params} );


// 店端库存查询
export const stockQuery = params => axios.post(`${SERVER.DMS_REPAIR}/oemPartStock/queryPartInfo`,  params );

// export const getListForExport = (params) => axios.get(`${SERVER.DMS_REPAIR}/oemPartStock/exportPartInfo`,  {
//   params,responseType: 'blob'
// });


//店端库存查询导出
export const getListForExport = params =>
  axios.get(`${SERVER.DMS_REPAIR}/oemPartStock/exportPartInfo`, {
    params,
    responseType: 'arraybuffer'
  });


// 异步导出
export const exporturl = params => axios.post(`/api/cmscloud.excel/downloadExcel/exportExcel/${params.CODE}`, params);

// 店端库存查询
export const selectList = params => axios.post(`${SERVER.CMSCLOUD_WMS}/part/stockTask/list`,  params );
